package com.tianqi.code.lottery.domain.strategy.service.draw;

import com.tianqi.code.lottery.domain.strategy.model.aggregates.StrategyRich;
import com.tianqi.code.lottery.domain.strategy.repository.IStrategyRepository;
import com.tianqi.code.lottery.infrastructure.po.Award;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DrawStrategySupport {

    @Resource
    protected IStrategyRepository strategyRepository;

    /**
     * 查询策略配置信息
     *
     * @param strategyId 策略ID
     * @return 策略配置信息
     */
    protected StrategyRich queryStrategyRich(Long strategyId){
        return strategyRepository.queryStrategyRich(strategyId);
    }

    /**
     * 查询奖品详情信息
     *
     * @param awardId 奖品ID
     * @return 中奖详情
     */
    protected Award queryAwardInfoByAwardId(String awardId){
        return strategyRepository.queryAwardInfo(awardId);
    }

    /**
     * 查询无库存排除奖品列表
     * @param strategyId
     * @return
     */
    public List<String> queryNoStockStrategyAwardList(Long strategyId) {
        return strategyRepository.queryNoStockStrategyAwardList(strategyId);
    }

    /**
     * 扣除库存
     * @param strategyId
     * @param awardId
     * @return
     */
    public boolean deductStock(Long strategyId, String awardId) {
        return strategyRepository.deductStock(strategyId, awardId);
    }

}
